package impl;

import java.util.ArrayList;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;

import api.InvalidAuthenticationException;
import api.ejb.IPhotos;

import javax.ejb.EJB;
import javax.ejb.Schedule;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;


import org.jboss.logging.Logger;

import p3_entities.Friend;
import p3_entities.Messageboard;
import p3_entities.Usermessage;
import p3_entities.Userphoto;
import p3_entities.Userprofile;


/**
 * Session Bean implementation class Socializer
 */
@Stateless(name = "IPhotos")
//@TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW)
public class Photos implements IPhotos {
	@PersistenceContext(unitName = "PhaseBookPU")
	EntityManager em;
	private static final Logger log = Logger.getLogger(Photos.class);


	static final long MILLIS_IN_A_DAY = 1000 * 60 * 60 * 24;

	/**
	 * Default constructor.
	 */
	public Photos() {
		// TODO Auto-generated constructor stub
	}

	
	@Override
	public int addPhoto(int uid, String photoPath) {
		log.info("Executing ---------->");

		Userphoto photo = new Userphoto();
		photo.setPhotoPath(photoPath);

		em.persist(photo);
		log.info("<--------------- Done");


		return photo.getId();

	}
}
